﻿using System;
using System.Threading;

namespace Basics106_ControlStructure
{
    /// <summary>
    /// Author: Mr. Jin Vincent N. Neceario
    /// Level: Beginner
    /// Problem: Write a program that prompts the user two integers and then prints
    /// The sum
    /// The difference
    /// The product
    /// The distance (absolute value of the difference)
    /// The maximum (the larger of the two)
    /// The minimum (the smaller of the two)
    /// </summary>
    class Program
    {
        static void Main(string[] args)
        {
            int firstnumber = 0;

            int secondnumber = 0;

            bool done = false;

            bool firstnumbervalid = false;

            bool secondnumbervalid = false;

            while (!done)
            {
                Console.Clear();

                Console.WriteLine("Input first number:");

                firstnumbervalid = int.TryParse(Console.ReadLine(), out firstnumber);

                Console.WriteLine("Input second number:");

                secondnumbervalid = int.TryParse(Console.ReadLine(), out secondnumber);

                if (firstnumbervalid && secondnumbervalid)
                {
                    done = true;
                }
                else 
                {
                    Console.WriteLine("Invalid number(s) was detected, Please try again");

                    Thread.Sleep(1000);
                }
            }

            Console.WriteLine("The sum of {0} + {1} = {2}", firstnumber, secondnumber, (firstnumber + secondnumber));

            Console.WriteLine("The difference of  {0} - {1} = {2}", firstnumber, secondnumber, (firstnumber - secondnumber));

            Console.WriteLine("The product of {0} * {1} = {2}", firstnumber, secondnumber, (firstnumber * secondnumber));

            Console.WriteLine("The average/mean of {0} & {1} is {2}", firstnumber, secondnumber, ((firstnumber + secondnumber) / 2));

            Console.WriteLine("The distance between {0} & {1} is {2}", firstnumber, secondnumber, (Math.Abs(firstnumber + secondnumber)));

            Console.WriteLine("The maximum of {0} & {1} is {2}", firstnumber, secondnumber, (Math.Max(firstnumber, secondnumber)));

            Console.WriteLine("The minimum of {0} & {1} is {2}", firstnumber, secondnumber, (Math.Min(firstnumber, secondnumber)));

            Console.ReadKey();
        }
    }
}
